package com.winexpress.sr;

import com.winexpress.entity.SalesReport;
import com.winexpress.session.sr.SalesReportSessionBean;
import java.io.IOException;
import java.security.SignatureException;
import java.text.ParseException;
import java.util.List;
import javax.ejb.EJB;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;

@WebService(serviceName = "SalesReportManagementWS")
public class SalesReportManagementWS {

    @EJB
    private SalesReportSessionBean salesReportSessionBean;

    @WebMethod(operationName = "ListSalesYear")
    public List<SalesReport> ListSalesYear() {
        List<SalesReport> salesYear = salesReportSessionBean.listSalesYear();
        //  System.out.println(salesYear.get(1).getSales());
        return salesYear;
    }

    @WebMethod(operationName = "SalesByYear")
    public List<SalesReport> SalesByYear(ReportObject obj) throws ParseException {

        String year = obj.getSingleYear();
        List<SalesReport> salesByYear = salesReportSessionBean.salesByYear(year);
        //  System.out.println(salesYear.get(1).getSales());
        return salesByYear;
    }

    @WebMethod(operationName = "SalesByPeriod")
    public SalesReport SalesByPeriod(ReportObject obj) throws ParseException {
        String fromYr = obj.getFromYr();
        String fromMth = obj.getFromMth();
        String fromDay = obj.getFromDay();
        String toYr = obj.getToYr();
        String toMth = obj.getToMth();
        String toDay = obj.getToDay();

        SalesReport salesByPeriod = salesReportSessionBean.salesByPeriod(fromYr, fromMth, fromDay, toYr, toMth, toDay);
        //  System.out.println(salesYear.get(1).getSales());
        return salesByPeriod;
    }

    @WebMethod(operationName = "SalesByPeriodProduct")
    public SalesReport SalesByPeriodProduct(ReportObject obj) throws ParseException {
        String fromYr = obj.getFromYr();
        String fromMth = obj.getFromMth();
        String fromDay = obj.getFromDay();
        String toYr = obj.getToYr();
        String toMth = obj.getToMth();
        String toDay = obj.getToDay();
        String wineid = obj.getWineid();
        SalesReport salesByPeriod = salesReportSessionBean.salesByPeriodProduct(fromYr, fromMth, fromDay, toYr, toMth, toDay, wineid);
        //  System.out.println(salesYear.get(1).getSales());
        return salesByPeriod;
    }

    @WebMethod(operationName = "SalesByPeriodCategory")
    public SalesReport SalesByPeriodCategory(ReportObject obj) throws ParseException {
        String fromYr = obj.getFromYr();
        String fromMth = obj.getFromMth();
        String fromDay = obj.getFromDay();
        String toYr = obj.getToYr();
        String toMth = obj.getToMth();
        String toDay = obj.getToDay();
        String catid = obj.getCatid();

        SalesReport salesByPeriod = salesReportSessionBean.salesByPeriodCategory(fromYr, fromMth, fromDay, toYr, toMth, toDay, catid);
        //  System.out.println(salesYear.get(1).getSales());
        return salesByPeriod;
    }

    @WebMethod(operationName = "Awis")
    public SalesReport Awis() throws SignatureException, IOException {
        SalesReport awis = salesReportSessionBean.Awis();
        return awis;
    }
}
